package com.isoft.filelistener.Utils;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.io.InputStream;

@Component
public class XmlUtils {
    public static ObjectMapper mapper = new XmlMapper();

    public static <T> T parseXml(InputStream input, Class<T> classType){
        try {
            mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
            return mapper.readValue(input, classType);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}
